package com.yjzx.util.common.util.batch.mergingLimit;

import org.apache.poi.ss.formula.functions.T;

import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Function;

/**
 * @author guozhi
 * @date 2025/1/14
 * @description PagingViewBuilder
 */
public final class PagingViewBuilder<T,R> {
    private T param;
    private Function<T, Integer> pageGet;
    private BiConsumer<T, Integer> pageSet;
    private Function<T, Integer> sizeGet;
    private BiConsumer<T, Integer> sizeSet;
    private List<PagingSlot<T, R>> list;

    private PagingViewBuilder() {
    }

    public static <T,R>PagingViewBuilder<T,R> aPagingView() {
        return new PagingViewBuilder<>();
    }

    public PagingViewBuilder<T,R> withParam(T param) {
        this.param = param;
        return this;
    }

    public PagingViewBuilder<T,R> withPageGet(Function<T, Integer> pageGet) {
        this.pageGet = pageGet;
        return this;
    }

    public PagingViewBuilder<T,R> withPageSet(BiConsumer<T, Integer> pageSet) {
        this.pageSet = pageSet;
        return this;
    }

    public PagingViewBuilder<T,R> withSizeGet(Function<T, Integer> sizeGet) {
        this.sizeGet = sizeGet;
        return this;
    }

    public PagingViewBuilder<T,R> withSizeSet(BiConsumer<T, Integer> sizeSet) {
        this.sizeSet = sizeSet;
        return this;
    }

    public PagingViewBuilder<T,R> withList(List<PagingSlot<T, R>> list) {
        this.list = list;
        return this;
    }

    public PagingView<T,R> build() {
        return new PagingView<>(param, pageGet, pageSet, sizeGet, sizeSet, list);
    }
}
